/* Start Header -------------------------------------------------------
Copyright (C) 2008 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the 
prior written consent of DigiPen Institute of Technology is prohibited.

File Name: InputControl.h
Purpose: Handling input
Language: C++ on Microsoft Visual Studio 2005
Platform: Microsoft Visual Studio 2005
          Supports shaders
Project: jmiller_CS300_1
Author: Jeremy Miller
        jmiller
        5002506
Creation date: 1 Oct 2008
- End Header --------------------------------------------------------*/
#ifndef INPUT_CONTROL_H
#define INPUT_CONTROL_H

#include <map>
#include <set>

// Low level data
typedef void (*DgtlProc)( void );
enum DgtlState { IDLE, TRIGGERED, PRESSED, RELEASED, COUNT };
typedef unsigned int MsgID;

// ProcList ( low level data  )
typedef std::set< DgtlProc > DgtlProcSet;
typedef DgtlProcSet::iterator DgtlProcSetIter;
typedef std::pair< DgtlProcSetIter, bool > DgtlProcInsertIter;

// State-to-ProcList mapping ( Mid level data )
typedef std::pair< DgtlState, DgtlProcSet > StatePair;
typedef std::map< DgtlState, DgtlProcSet > DgtlStateMap;
typedef DgtlStateMap::iterator DgtlStateIter;
typedef std::pair< DgtlStateIter, bool > DgtlStateInsertIter;

// Msg-to-StateProcList mapping ( High level data )
typedef std::pair< MsgID, DgtlStateMap > MsgPair;
typedef std::map< MsgID, DgtlStateMap > DtglMsgMap;
typedef DtglMsgMap::iterator DgtlMsgIter;
typedef std::pair< DgtlMsgIter, bool > DgtlMsgInsertIter;

// Msg-toState mapping ( High level data )
typedef std::pair< MsgID, DgtlState > MsgStatePair;
typedef std::map< MsgID, DgtlState > MsgStateMap;
typedef MsgStateMap::iterator MsgStateIter;

class Input {
  public:
    DgtlProc RegisterDgtlProc( MsgID id, DgtlState state, DgtlProc proc );
    DgtlProc UnregisterDgtlProc( MsgID id, DgtlState state, DgtlProc proc );

    void RegisterMsgforUpdate( MsgID id, DgtlState initState = RELEASED );
    void UnregisterMsgforUpdate( MsgID id );

    void Update();
    void SetDown( MsgID id );
    void SetUp( MsgID id );

  private:
    MsgStateMap curDgtlStates;
    DtglMsgMap  digitalMap;
};

#endif
